﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ozone.Models
{
    public class CommCfg
    {
        //通讯类型 0：网口 1：串口
        public string CommType { get; set; }
        public string Port { get; set; }
        public string Baud { get; set; }
        public string IP { get; set; }

        public CommCfg(string cfgStr)
        {
            string[] sArray = cfgStr.Split(',');
            if(sArray.Length == 2)
            {
                if(sArray[0] == "0")
                {
                    CommType = "0";
                    string[] sA = sArray[1].Split(':');
                    if(sA.Length == 2)
                    {
                        IP = sA[0];
                        Port = sA[1];
                    }
                }
                else
                {
                    CommType = "1";
                    Port = sArray[1];
                    string[] sA = sArray[1].Split(':');
                    if (sA.Length == 2)
                    {
                        Port = sA[0];
                        Baud = sA[1];
                    }
                }
            }
           
        }
    }
}
